<?php
/**
 * [Idea XML News Aggregator]
 * 
 * @home
 * @author : Zxsv
 * @version 0.5
 * @$Id: index.php
 **/

require_once('global.php');
if ($_GET['action'] == 'login') {
include template("login", _ROOT ."/template/digg/");
}elseif($_GET['action'] == 'register') {
include template("register", _ROOT ."/template/digg/");
}elseif($_GET['action'] == 'profile') {
include template("profile", _ROOT ."/template/digg/");
}elseif($_GET['action'] == 'logout') {
	setcookie('ixnauid', '');
	setcookie('comment_post_time', '');
	setcookie('search_post_time', '');
	setcookie('comment_username', '');
	setcookie('comment_url', '');

	message('注销成功', './');
}else{
$is_run = $_COOKIE["is_run"];
if($is_run!='yes'){
	$is_run='no';
	setcookie("is_run","yes");
}
$site = is_string($_GET[site]) ? $_GET[site]:"";
if (!empty($site)){
    $arg = $site > "" ? " and siteid='$site' ":"";
}else{
    $arg .= "";
}
$cid = is_string($_GET[cid]) ? $_GET[cid]:"";
if (!empty($cid)){
    $arg = $cid > "" ? " and cid='$cid' ":"";
}else{
    $arg .= "";
}
		if (!empty($cid)) {			
			$tatol = $catecache['feed_count'];
			$pageurl .= '&amp;cid='.$cid;
		}elseif(!empty($site)){
			$tatol = $catecache['feed_count'];
			$pageurl .= '&amp;site='.$site;
		}else{
			$tatol = $stats['feed_count'];					
			$pageurl = './index.php';
		}
	$pagenum = 20;	
		if($page) {
			$start_limit = ($page - 1) * $pagenum;
		} else {
			$start_limit = 0;
			$page = 1;
		}
$query = $db->query("SELECT *  FROM {$tablepre}xna_feed WHERE state!=0 $arg order by $hots state desc,addtime desc LIMIT $start_limit,$pagenum");

$multipage = multi($tatol, $pagenum, $page, $pageurl);	
while ($row=$db->row($query)){
	$row[id] = $row["feedid"];
    $row[title] = $row["feed_title"];
    $row[content] = $row["feed_description"];
    $row[addtime] = date("Y-m-d H:m:s",$row["addtime"]);
    $n++;
    $feed[] = $row;
}
include template("index", _ROOT ."/template/digg/");
}
?>